package com.pay.plat.auth;

import java.util.Map;

import com.pay.resource.SpringBeanResource;

import cn.hutool.core.util.StrUtil;


/**
 * 权限session
 * 主要是用于前端的一些权限检测
 * @author tianpeng
 *
 */
public class AuthoritySession {
	
	public static final String PERMISSIONS = "permissions" ;
	
	/**
	 * 认证
	 * @param url
	 * @param request
	 * @return
	 */
	public static Boolean isAuth(Integer loginId,String url) {
		String menuName =  (String) SpringBeanResource.redisTemplate.opsForHash().get(loginId + "=" + PERMISSIONS, url);
		if(StrUtil.isBlank(menuName)) {
			return false ;
		}
		return true ;
	}
	
	/**
	 * 赋权
	 */
	public static void setPermissions(Integer loginId,Map<String,String> permissions) {
		SpringBeanResource.redisTemplate.opsForHash().putAll(loginId + "=" + PERMISSIONS, permissions);
	}
}

